<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title> Company List</title>

    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/font-awesome/css/font-awesome.css}" rel="stylesheet"/>

    <link th:href="@{/css/plugins/toastr/toastr.min.css}" rel="stylesheet" />

    <link th:href="@{/css/animate.css}" rel="stylesheet"/>
    <link th:href="@{/css/style.css}" rel="stylesheet"/>
    <style>
        .btn-custom {
            margin-bottom: 5px;
            margin-top: 22px;
        }
    </style>

</head>
<body>
<div id="wrapper">
    <div th:include="common/navbar_left :: navbar_left"></div>
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom" th:include="common/navbar_header :: navbar_header"></div>
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>Search Company</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="#">Home</a>
                    </li>
                    <li class="active">
                        <strong>Companies</strong>
                    </li>
                </ol>
            </div>
            <div class="col-lg-2">

            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <form method="post" th:action="@{/company/search}">
                                <div class="row">
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="control-label" for="name">User Name</label>
                                            <input type="text" id="name" name="name" th:value="${company.name}"
                                                   placeholder="User Name" class="form-control"/>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="control-label" for="email">Email</label>
                                            <input type="text" id="email" name="email" th:value="${company.email}"
                                                   placeholder="Email" class="form-control"/>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="control-label" for="location">Location</label>
                                            <input type="text" id="location" name="location" th:value="${company.location}"
                                                   placeholder="location" class="form-control"/>
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="control-label" for="headquarter">Headquarter</label>
                                            <input type="text" id="headquarter" name="headquarter" value=""
                                                   placeholder="Headquarter" class="form-control"/>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="control-label" for="industry">Industry</label>
                                            <input type="text" id="industry" name="industry" value=""
                                                   placeholder="Industry" class="form-control"/>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="control-label" for="remark">Description</label>
                                            <input type="text" id="remark" name="remark" th:value="${company.remark}"
                                                   placeholder="Description" class="form-control"/>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary btn-custom">Search</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>Company List</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content" style="">
                            <table class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th>User ID</th>
                                    <th>User Name</th>
                                    <th>Email</th>
                                    <th>Location</th>
                                    <th>Headquarter</th>
                                    <th>Industry</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="c,index: ${companyList}">
                                    <th class="col-md-1" th:text="${index.index} + 1"></th>
                                    <th class="col-md-1" th:text="${c.cId}"></th>
                                    <th class="col-md-1" th:text="${c.name}"></th>
                                    <th class="col-md-2" th:text="${c.email}"></th>
                                    <th class="col-md-2" th:text="${c.location}"></th>
                                    <th class="col-md-2" th:text="${c.headquarter}"></th>
                                    <th class="col-md-2" th:text="${c.industry}"></th>
                                    <th class="col-md-1">
                                        <a th:href="@{/company/detail(cId = ${c.cId})}"><i class="fa fa-check text-navy"> Detail</i></a>
                                        &nbsp;&nbsp;&nbsp;&nbsp;
                                        <a th:if="${session.user_flag} == '0'" th:onclick="'sendMsg(\''+${c.cId}+'\')'">
                                            <i class="fa fa-check text-navy">
                                                <span>Follow</span></i>
                                        </a>
                                    </th>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer">
            <div>
                <strong>Copyright</strong> Jobster &copy; 2018
            </div>
        </div>

    </div>
</div>
<!-- Mainly scripts -->
<div th:include="common/common_js :: common_js"></div>

<!-- Custom and plugin javascript -->
<script th:src="@{/js/inspinia.js}"></script>

<script th:src="@{/js/plugins/toastr/toastr.min.js}"></script>

<script th:inline="javascript" type="text/javascript">
    //<![CDATA[
    $(function () {

    });
    var basePath =[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];
    function sendMsg(cId){
        $.ajax({
            url : basePath +"/message/apply/company",
            type : "GET",
            contentType: "application/json;charset=utf-8",
            data : {'cId':cId},
            dataType : "json",
            success : function(result) {
                toastr.success(result.respMessage);
            },
            error:function(msg){
                console.info(msg);
                toastr.warn(msg);
            }
        })
    }
    
    toastr.options = {
        "closeButton": true,
        "debug": false,
        "progressBar": true,
        "preventDuplicates": false,
        "positionClass": "toast-top-right",
        "onclick": null,
        "showDuration": "400",
        "hideDuration": "1000",
        "timeOut": "7000",
        "extendedTimeOut": "1000",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    }
    //]]>
</script>
</body>
</html>
